<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户信息登记 - BIG Data Center</title>
    <script src="${host}/static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            if (($("#roleselect").val()) == "PI/Senior Scientist") {
                $(".isPI").show();
            }


            if ($(".isInvited").is(":checked")) {
                $(".report").show();
                $("#title").prop('required',true);
            }


            $("#roleselect").change(function () {
                var val = $("#roleselect").val();
                if (val == "PI/Senior Scientist") {
                    $(".isPI").show();
                } else {
                    $(".isPI").hide();
                }


            });
            $(".isInvited").bind("click", function (event) {
                $(".report").show();
                $("#title").prop('required',true);
            });
            $(".noInvited").bind("click", function (event) {
                $(".report").hide();
                $("#title").prop('required',false);
            });
        });
    </script>
</head>
<body>
<div class="index">
    <h3 class="text-primary">请完善您的个人信息</h3>
    <p class="text-danger">* 请确保您的信息真实有效, 以便通过管理员审核</p>
    <c:if test="${message != null}">
        <div class="alert alert-success alert-dismissible fade in"
             role="alert">
            <button type="button" class="close" data-dismiss="alert"
                    aria-label="Close">
                <span aria-hidden="true">×</span>
            </button>
            <strong>Congratulations!${message}</strong>
        </div>
    </c:if>



    <%--   <!------------------------------------ 头像上传------------------------------------>
      <form class="form-inline" method="post" action="${host}/ybp/upload"
          enctype="multipart/form-data">

          <c:if test="${user.picPath!= null}">
              <img src="${host}${user.picPath}" height="240" />
              <br>
          </c:if>
          <div class="input-group">
              <span class="input-group-addon">上传头像:</span> <input type="file"
                  class="form-control" name="file" style="width: 200px">
          </div>
          <div class="input-group">
              <input type="hidden" name="id" value="${user.id}" />
              <button type="submit" class="btn btn-success">
                  <i class="fa fa-upload"></i> Upload
              </button>
              <label>${image}</label>
          </div>
      </form>
      <hr> --%>
    <!------------------------------------ 表单------------------------------------>
    <form class="form-horizontal" method="post"
          action="${host}/ybp/update">

        <div class="form-group">
            <label class="col-md-2 control-label">用户状态: </label>
            <div class="col-md-5">
                <c:if test="${user.status == 1}">
                    <span class="form-control text-primary" disabled="true">待审核</span>
                </c:if>
                <c:if test="${user.status == 2}">
                    <span class="form-control text-success">审核通过</span>
                </c:if>
            </div>
        </div>
       <c:if test="${issuperadmin!= null}">
        <div class="form-group">
            <label class="control-label col-md-2">用户权限: </label>
            <div class="col-md-5">

                <div class="checkbox-inline">
                    <label>
                        <input type="checkbox" value="1" name="roleID"
                                <c:forEach items="${user.ybpRoleList}" var="ybpRole" >
                                    <c:if test="${ybpRole.id== 1}"> checked</c:if >
                                </c:forEach>
                        />ADMIN
                    </label>
                </div>
                <div class="checkbox-inline">
                    <label>
                        <input type="checkbox" value="2" name="roleID"
                                <c:forEach items="${user.ybpRoleList}" var="ybpRole" >
                                    <c:if test="${ybpRole.id== 2}"> checked</c:if >
                                </c:forEach>
                        />USER
                    </label>
                </div>
                <div class="checkbox-inline">
                    <label>
                        <input type="checkbox" value="3" name="roleID"
                                <c:forEach items="${user.ybpRoleList}" var="ybpRole">
                                    <c:if test="${ybpRole.id== 3}"> checked</c:if >
                                </c:forEach>
                        />SUPERADMIN
                    </label>
                </div>




            </div>
        </div>
           </c:if>


        <div class="form-group">
            <label class="control-label col-md-2">邮箱: </label>
            <div class="col-md-5">
                <span class="form-control text-primary" disabled="true">${user.email}</span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2">姓名: </label>
            <div class="col-md-5">
                <input type="text" value="${user.username}" name="username"
                       class="form-control" required/>
            </div>
        </div>


        <div class="form-group">
            <label class="control-label col-md-2">单位: </label>
            <div class="col-md-5">
                <input type="text" value="${user.department}" name="department"
                       class="form-control" required/>
            </div>
        </div>


        <div class="form-group">
            <label class="control-label col-md-2">电话: </label>
            <div class="col-md-5">
                <input type="text" value="${user.telephone}" name="telephone"
                       class="form-control" required/>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2">用户角色: </label>
            <div class="col-md-5">
                <select id="roleselect" name="userType"
                        class="form-control" required>
                    <option>${user.userType}</option>
                    <option value="PI/Senior Scientist" <c:if
                            test="${user.userType eq 'PI/Senior Scientist' }"> selected="selected"</c:if>>PI/Senior
                        Scientist
                    </option>
                    <option value="Postdoc/Junior Scientist" <c:if
                            test="${user.userType eq 'Postdoc/Junior Scientist' }"> selected="selected"</c:if>>
                        Postdoc/Junior
                        Scientist
                    </option>
                    <option value="Student" <c:if test="${user.userType eq 'Student' }"> selected="selected"</c:if>>
                        Student
                    </option>
                    <option value="Other" <c:if test="${user.userType eq 'Other' }"> selected="selected"</c:if> >Other
                    </option>

                </select>
            </div>
        </div>


        <div class="form-group">
            <label class="control-label col-md-2">是否需要13号午餐:</label>
            <c:if test="${user.thirteenLunch == 1 || user.thirteenLunch == null}">
                <label class="radio-inline"><input type="radio"
                                                   name="thirteenLunch" value=0>Yes</label>
                <label class="radio-inline"> <input type="radio"
                                                    name="thirteenLunch" value=1 checked/>NO
                </label>
            </c:if>

            <c:if test="${user.thirteenLunch == 0}">
                <label class="radio-inline "><input type="radio"
                                                    name="thirteenLunch" value=0 checked>Yes</label>
                <label class="radio-inline "> <input type="radio"
                                                     name="thirteenLunch" value=1>NO
                </label>
            </c:if>
        </div>


        <section class="isPI" style="display: none">
            <div class="form-group">
                <label class="control-label col-md-2">是否参加12号晚餐:</label>
                <c:if test="${user.twelveDinner == 1 || user.twelveDinner == null}">
                    <label class="radio-inline"><input type="radio"
                                                       name="twelveDinner" value=0>Yes</label>
                    <label class="radio-inline"> <input type="radio"
                                                        name="twelveDinner" value=1 checked>No
                    </label>
                </c:if>

                <c:if test="${user.twelveDinner == 0}">
                    <label class="radio-inline"><input type="radio"
                                                       name="twelveDinner" value=0 checked>Yes</label>
                    <label class="radio-inline"> <input type="radio"
                                                        name="twelveDinner" value=1>No
                    </label>
                </c:if>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">是否参加13号晚餐:</label>
                <c:if
                        test="${user.thirteenDinner == 1 || user.thirteenDinner == null}">
                    <label class="radio-inline"><input type="radio"
                                                       name="thirteenDinner" value=0>Yes</label>
                    <label class="radio-inline"> <input type="radio"
                                                        name="thirteenDinner" value=1 checked>No
                    </label>
                </c:if>

                <c:if test="${user.thirteenDinner == 0}">
                    <label class="radio-inline"><input type="radio"
                                                       name="thirteenDinner" value=0 checked>Yes</label>
                    <label class="radio-inline"> <input type="radio"
                                                        name="thirteenDinner" value=1>No
                    </label>
                </c:if>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">讨论议题: </label>
                <div class="col-md-5">
                    <textarea rows="4" name="issue" class="form-control" placeholder="例如：生物信息学是否需要做实验? 如何评价生物信息学研究及学者的水平?">${user.issue}</textarea>
                </div>
            </div>


            <div class="form-group">
                <label class="control-label col-md-2">是否是特邀报告人:</label>
                <c:if test="${user.isInvited == 1 || user.isInvited == null}">
                    <label class="radio-inline"><input type="radio"
                                                       name="isInvited" class="isInvited" value=0>Yes</label>
                    <label class="radio-inline"> <input type="radio"
                                                        name="isInvited" class="noInvited" value=1 checked/>NO
                    </label>
                </c:if>

                <c:if test="${user.isInvited == 0}">
                    <label class="radio-inline "><input type="radio"
                                                        name="isInvited" class="isInvited" value=0 checked>Yes</label>
                    <label class="radio-inline "> <input type="radio"
                                                         name="isInvited" class="noInvited" value=1>NO
                    </label>
                </c:if>
            </div>


            <section class="report" style="display: none">
                <div class="form-group">
                    <label class="control-label col-md-2">报告题目: </label>
                    <div class="col-md-5">
                        <input type="text" value="${user.reportTitle}" name="reportTitle" id="title"
                               class="form-control"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-md-2">报告摘要: </label>
                    <div class="col-md-5">
                        <textarea rows="4" name="reportAbstract" class="form-control">${user.reportAbstract}</textarea>
                    </div>
                </div>


                <div class="form-group">
                    <label class="control-label col-md-2">报告人简介: </label>
                    <div class="col-md-5">
                        <textarea rows="4" name="userSummary" class="form-control">${user.userSummary}</textarea>
                    </div>
                </div>

            </section>
        </section>
        <input type="hidden" name="id" value="${user.id}"/>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-2">
                <button type="submit" class="btn btn-primary">更新</button>

            </div>

        </div>

    </form>

</div>

</body>

</html>
